package com.njworkorder.Service.Impl;

import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.njworkorder.Entity.BillOfQuantities;
import com.njworkorder.Entity.MeteringInventory;
import com.njworkorder.Entity.PlanMetering;
import com.njworkorder.Service.BillOfQuantitiesService;
import com.njworkorder.Mapper.BillOfQuantitiesMapper;
import com.njworkorder.VO.AssignmentProgressVos.MaintenanceMeteringInfo;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.CompletableFuture;

/**
* @author iron
* @description 针对表【bill_of_quantities】的数据库操作Service实现
* @createDate 2024-11-25 10:19:25
*/
@Service
public class BillOfQuantitiesServiceImpl extends MPJBaseServiceImpl<BillOfQuantitiesMapper, BillOfQuantities>
    implements BillOfQuantitiesService{

    @Async
    @Override
    public CompletableFuture<List<MaintenanceMeteringInfo>> getMeteringInfo(String assignmentId) {


        MPJLambdaWrapper<BillOfQuantities> wrapper = new MPJLambdaWrapper<BillOfQuantities>()

                .selectAs(BillOfQuantities::getNums,MaintenanceMeteringInfo::getNums)
                .selectAs(BillOfQuantities::getUnit,MaintenanceMeteringInfo::getUnit)
                .selectAs(BillOfQuantities::getUnitPrice,MaintenanceMeteringInfo::getUnitPrice)
                .selectAs(BillOfQuantities::getStatus,MaintenanceMeteringInfo::getStatus)

                .selectAs(PlanMetering::getIsSpecial,MaintenanceMeteringInfo::getIsSpecial)
                .selectAs(MeteringInventory::getProjectName,MaintenanceMeteringInfo::getProjectName)

                .leftJoin(PlanMetering.class,PlanMetering::getId,BillOfQuantities::getMcId)
                .leftJoin(MeteringInventory.class,MeteringInventory::getId,PlanMetering::getMeteringInventoryId)

                .eq(BillOfQuantities::getJobManagementId,assignmentId);

        return CompletableFuture.completedFuture(selectJoinList(MaintenanceMeteringInfo.class, wrapper));
    }
}




